package com.data.datalib.util

import android.content.Context
import android.content.pm.PackageManager

fun Context.checkPermissionsGranted(list: List<String>): Boolean {
    val notGranted = list.any {
        checkSelfPermission(it) != PackageManager.PERMISSION_GRANTED
    }
    return !notGranted
}

fun String?.safe(): String {
    if (this.isNullOrBlank()) return ""
    return this
}

fun String?.safeInt(): Int {
    if (this.isNullOrBlank()) return 0
    return try {
        this.toInt()
    } catch (e: Exception) {
        0
    }
}

fun String.lastPath(): String {
    return replace("/", "")
}

fun String.removePathSeparator(): String {
    return replace("/", "")
}

fun String.addPathSeparator(): String {
    val newState = replace("/", "")
    return "/$newState"
}


